﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>客户目录管理</title>
    <#include "../common/link.ftl">
    <script>
        $(function () {
            $('.btn-input').click(function () {
                $('#myModal').modal('show')
            })

            //当提交是submit的时候
            $('#editForm').ajaxForm(handlerMessage)
            //回来
            $('.btn-input').click(function () {
                //清除模态框的数据
                $("#editForm input").val('');
                //获取事件源绑定的数据 使用data方法可以很方便获取data-*开头的属性的数据
                var json = $(this).data("json");
               /* if (json) { //json有数据代表是编辑
                    $("#editForm input[name=id]").val(json.id);
                    $("#editForm input[name=title]").val(json.title);
                    $("#editForm input[name=intro]").val(json.intro);
                    $("#editForm input[name=sn]").val(json.sn);
                }*/
            })

            $(".btn-delete").click(function () {
                //获取当前点击的客户目录id
                var id = $(this).data('id');
                //提示确认框
                $.messager.confirm("警告","是否确认删除?",function () {
                    //发送ajax请求
                    $.get('/customer/delete.do',{id:id},handlerMessage)
                })
            })
        })


    </script>

</head>
<body class="hold-transition skin-blue sidebar-mini">
<div class="wrapper">
    <#include "../common/navbar.ftl">
    <!--菜单回显-->
    <#assign currentMenu="customer_pool">
    <#include "../common/menu.ftl">
    <div class="content-wrapper">
        <section class="content-header">
            <h1>客户目录管理</h1>
        </section>
        <section class="content">
            <div class="box"> <!--高级查询--->
                <form class="form-inline" id="searchForm" action="/customer/poolList" method="post">
                    <input type="hidden" name="currentPage" id="currentPage" value="1">
                    <div class="form-group">
                        <label for="keyword">关键字:</label>
                        <input type="text" class="form-control" id="keyword" name="keyword"
                               value="" placeholder="请输入姓名/邮箱">
                    </div>
                <#--只能是管理员或者是经理能够看到-->
                    <@shiro.hasAnyRoles name="ADMIN,Market_Manager">
                    <div class="form-group">
                        <label for="sellerId"> 销售员:</label>
                        <select class="form-control" id="sellerId" name="sellerId">
                            <option value="-1">全部</option>
                           <#list employees! as seller>
                                <option value="${seller.id!}">${seller.name!}</option>
                           </#list>
                        </select>
                        <script>
                            $('#sellerId').val(${qo.sellerId!})
                        </script>
                    </div>
                    </@shiro.hasAnyRoles>
                    <button id="btn_query" class="btn btn-primary"><span class="glyphicon glyphicon-search"></span>
                        查询
                    </button>
                </form>
                <!--编写内容-->
                <div class="box-body table-responsive no-padding ">
                    <table class="table table-hover table-bordered">
                        <tr>
                            <th>编号</th>
                            <th>客户名字</th>
                            <th>客户年龄</th>
                            <th>客户性别</th>
                            <th>客户号码</th>
                            <th>客户qq</th>
                            <th>客户职业</th>
                            <th>客户来源</th>
                            <th>销售</th>
                            <th>录入人</th>
                            <th>录入时间</th>
                            <th>状态</th>
                            <th>操作</th>
                        </tr>
                    <#list PageResult.list as customer >
                        <tr>
                            <td>${customer_index+1}</td>
                            <td>${customer.name!}</td>
                            <td>${customer.age!}</td>
                            <td>${customer.gender!}</td>
                            <td>${customer.tel!}</td>
                            <td>${customer.qq!}</td>
                            <td>${(customer.job.title)!}</td>
                            <td>${(customer.source.title)!}</td>
                            <td>${(customer.seller.name)!}</td>
                            <td>${(customer.inputUser.name)!}</td>
                            <td>${(customer.inputTime?string('yyyy-MM-dd'))!}</td>
                            <td>${customer.statusName!}</td>
                            <td>
                                <a href="#" data-json='${(customer.json)!}'
                                   class="btn btn-info btn-xs btn-absorb">
                                    <span class="glyphicon glyphicon-pencil"></span> 吸纳
                                </a>
                                <a href="#" data-json='${(customer.json)!}'
                                   class="btn btn-info btn-xs btn-Transfer ">
                                    <span class="glyphicon glyphicon-pencil"></span>移交
                                </a>

                            </td>
                        </tr>
                    </#list>
                    </table>
                    <!--分页-->
                    <#include "../common/page.ftl">
                </div>
            </div>
        </section>
    </div>
    <#include "../common/footer.ftl">
</div>
<!-- Modal 模态-->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 class="modal-title" id="myModalLabel">添加/修改</h4>
            </div>
            <form class="form-horizontal" action="/customer/saveOrUpdate" method="post" id="editForm">
                <div class="modal-body">
                </div>
                <input type="hidden" name="id">
                <div class="form-group" style="margin-top: 10px;">
                    <label for="title" class="col-sm-3 control-label">标题：</label>
                    <div class="col-sm-5">
                        <input type="text" class="form-control"  name="title"
                               placeholder="请输入客户标题">
                    </div>
                </div>
                <div class="form-group" style="margin-top: 10px;">
                    <label for="sn" class="col-sm-3 control-label">编码：</label>
                    <div class="col-sm-5">
                        <input type="text" class="form-control" id="sn" name="sn"
                               placeholder="请输入客户目录编码">
                    </div>
                </div>
                <div class="form-group" style="margin-top: 10px;">
                    <label for="intro" class="col-sm-3 control-label">简介：</label>
                    <div class="col-sm-5">
                        <input type="text" class="form-control"  name="intro"
                               placeholder="请输入客户目录简介">
                    </div>
                </div>

                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                    <button type="submit" class="btn btn-primary btnSubmit">确定</button>
                </div>
            </form>
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div><!-- /.modal -->
</body>
</html>
